package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CPService;
import com.yixun.qfbao.api.service.M2Servcie;
import com.yixun.qfbao.apidto.GetM2ProjectsReqDto;
import com.yixun.qfbao.apidto.GetM2ProjectsResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.model.PartnerInfo;
import com.yixun.qfbao.service.PartnerInfoService;
import com.yixun.qfbao.utils.LoginUtils;
import com.yixun.qfbao.vo.GetM2ProjectsReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 获取M2楼盘
 * 	分页
 * @author JHSong
 *		
 */
@Service("getM2ProjectsHander")
public class GetM2ProjectsHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(GetM2ProjectsHander.class);
	
	@Autowired
	private M2Servcie m2Servcie;
	@Autowired
	private LoginUtils loginUtils;
	@Autowired
	private PartnerInfoService partnerInfoService;

	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetM2ProjectsReqVo req = (GetM2ProjectsReqVo)reqDto;
		GetM2ProjectsReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetM2ProjectsResDto> res = new BaseResponseDTO<GetM2ProjectsResDto>();
		GetM2ProjectsResDto resDto = new GetM2ProjectsResDto();
		try {
			PartnerInfo partnerInfo = partnerInfoService.selectById(Long.valueOf(reqDto1.getUserId()));
			reqDto1.setHigherId(partnerInfo.getHigherid());
			resDto = m2Servcie.getM2Projects(reqDto1);
		} catch (Exception e) {
			logger.error("GetM2ProjectsHander error: {}", e);
			resDto.setResultMsg("获取报备分页失败," + e.getMessage());
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
